package com.cj.MyQuery;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cj.Mapper.BooksMapper;
import com.cj.MyServices.IBook;
import com.cj.models.BookList;
import com.cj.models.BookModel;
import com.cj.models.PageInfo;
import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public class BookQuery extends ServiceImpl<BooksMapper,BookModel>
        implements IBook,GraphQLQueryResolver {

    public BookList list(int page, int size){
        Page<BookModel> p = new Page<>(page,size);
        return new BookList(this.page(p).getRecords(),
                PageInfo.build(p.getTotal(),p.getSize(),p.getCurrent()));

    }
}
